#include "MapManager.hpp"

vector<MapData> MapManager::mMaps;
int				MapManager::mNextID = 0;
vector<string>	MapManager::mNormalImages;
vector<string>	MapManager::mMouseoverImages;

MapData MapManager::GetMap(string mapName)
{
	// Find our map
	for(unsigned int i = 0; i < mMaps.size(); ++i)
	{
		if(mMaps[i].MapName == mapName)
		{
			return mMaps[i];
		}
	}
	MapData badMap;
	badMap.MapName = "badMap";
	badMap.MapPath = "badMap";
	badMap.NavPath = "badMap";
	return badMap;
}

vector<MapData> MapManager::GetAllMaps()
{
	return mMaps;
}

void MapManager::AddMap(string mapName, string normalImage, string mouseoverImage)
{
	MapData mapData;
	mapData.NavPath		=	"nothing.nav";
	mapData.MapPath		=	"nothing.map";
	mapData.MapScript	=	"nothing.lua";
	mapData.MapName		=	mapName;
	mapData.w			=	100;
	mapData.h			=	100;

	mapData.ID			=	mNextID;
	mNextID				+=	1;

	mMaps.push_back(mapData);

	mNormalImages.push_back(normalImage);
	mMouseoverImages.push_back(mouseoverImage);
}

void MapManager::SetMapPaths(string mapName, string mapPath, string navPath, string mapScript)
{
	// Find our map
	for(unsigned int i = 0; i < mMaps.size(); ++i)
		if(mMaps[i].MapName == mapName)
		{
			mMaps[i].MapPath = mapPath;
			mMaps[i].NavPath = navPath;
			mMaps[i].MapScript = mapScript;
		}
}

void MapManager::SetMapDimensions(string mapName, const int& w, const int& h)
{
	// Find our map
	for(unsigned int i = 0; i < mMaps.size(); ++i)
		if(mMaps[i].MapName == mapName)
		{
			mMaps[i].w = w;
			mMaps[i].h = h;
		}
}

string MapManager::GetNormalImage(string mapName)
{
	// Find our map
	for(unsigned int i = 0; i < mMaps.size(); ++i)
		if(mMaps[i].MapName == mapName)
		{
			return mNormalImages[i];
		}

	return "unable to locate normal image in MapManager";
}
string MapManager::GetMouseoverImage(string mapName)
{
	// Find our map
	for(unsigned int i = 0; i < mMaps.size(); ++i)
		if(mMaps[i].MapName == mapName)
		{
			return mMouseoverImages[i];
		}

	return "unable to locate mouseover image in MapManager";
}